Next | Prev | Up | Top | Contents | Index
Using Direct I/O
You can avoid both sources of delay by using the option O_DIRECT. Under this option, writes to the file take place directly from your program's buffer--the data is not copied to a buffer in the kernel first. In order to use O_DIRECT you are required to transfer data in quantities that are multiples of the disk blocksize. This ensures that a block is written only once. (The requirements for O_DIRECT use are documented in the open(2) and fcntl(2) reference pages.)
Control does not return from an O_DIRECT read() or write() until the disk write is complete. However, you can open a file O_DIRECT and use the use file descriptor for asynchronous I/O.
Next | Prev | Up | Top | Contents | Index